/**
 * @FileName: T_NettyServer.java
 * @Package: com.ziroom.sms.std.service
 * @author liusq23
 * @created 2017/6/15 下午4:46
 * <p>
 * Copyright 2015 ziroom
 */
package com.ziroom.sms.std.service;

import com.ziroom.sms.std.netty.NettyClient;
import com.ziroom.sms.std.netty.NettyClientRpcHandler;
import com.ziroom.sms.std.netty.NettyServer;
import com.ziroom.sms.std.rpc.InvokerInvocationHandler;
import com.ziroom.sms.std.rpc.SmsdboInvocation;
import com.ziroom.sms.std.rpc.proxyfacotry.JDKProxyFactory;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import org.junit.Test;

/**
 * <p></p>
 *
 * <PRE>
 * <BR>	修改记录
 * <BR>-----------------------------------------------
 * <BR>	修改日期			修改人			修改内容
 * </PRE>
 *
 * @author liusq23
 * @since 1.0
 * @version 1.0
 */
public class T_NettyServer {

    private static final int DEFAULT_PORT = 20880;
    private static final String DEFAULT_HOST = "127.0.0.1";

    @Test
    public void t_open() throws Exception{
        NettyServer nettyServer = new NettyServer();
        nettyServer.open("127.0.0.1",20880);
        System.in.read();
    }

    @Test
    public void testClientStart() throws Exception {
        NettyClientRpcHandler rpcHandler = new NettyClientRpcHandler();
        NettyClient nettyClient = new NettyClient(DEFAULT_HOST,DEFAULT_PORT,rpcHandler);
        nettyClient.start();
        Thread.sleep(1000);
        rpcHandler.sendRpcInvoke(new SmsdboInvocation());
//        InvokerInvocationHandler invocationHanlder = new InvokerInvocationHandler(rpcHandler);
//        JDKProxyFactory factory = new JDKProxyFactory();
//        IHelloWorld helloService = factory.getProxy(new Class<?>[]{IHelloWorld.class},invocationHanlder);
//        String s = helloService.sayHello("hello");
//        System.out.println(s);
    }
}
